home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug106 / util1.c < prev    next >
C/C++ Source or Header  |  1984-06-14  |  1KB  |  58 lines

  1. /*
  2.         Function Summary
  3.         ----------------
  4.  
  5. charcnt(bufpntr)
  6.  
  7.     returns the number of characters in the file at bufpntr.
  8.     file must be in a continuous block of RAM.
  9.  
  10. linecnt(bufpntr)
  11.  
  12.     returns the number of lines in the file at bufpntr.
  13.     file must be in a continuous block of RAM.
  14.  
  15. ntoi(number,base)
  16.  
  17.     converts ASCII digits to an integer using any base
  18.     except split octal (see otoi). white space may preceed
  19.     the ASCII string which must end with '\0' after the
  20.     final digit.
  21.  
  22. otoi(number)
  23.  
  24.     converts ASCII digits representing a split octal
  25.     number in the format xxx.xxx{a} to an integer. white
  26.     space may preceed the ASCII string which must be
  27.     7 characters long (3 chars,'.',3 chars). any following
  28.     characters are ignored (ie. does not require '\0' as
  29.     final delimiter).
  30.  
  31. wordcnt(bufpntr)
  32.  
  33.     returns the number of words in the file at bufpntr.
  34.     file must be in a continuous block of RAM. note that
  35.     '\n' is handled explicitly as CRLF to avoid false
  36.     triggering of the word count on an empty line.
  37. */
  38.  
  39. #define    LF    10
  40. #define    CR    13
  41. #define    EOF    26
  42. #define    NO    0
  43. #define    YES    -1
  44.  
  45. charcnt(bufpntr)
  46. char *bufpntr;
  47. {
  48.     int nc;
  49.     char c;
  50.  
  51.     nc = 0;
  52.     while((c = *bufpntr++) != EOF) nc += 1;
  53.     return nc;
  54. }
  55.  
  56. linecnt(bufpntr)
  57. char *bufpntr;
  58. {